home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / OptionsCompressionPage.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  4KB  |  101 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #include "stdafx.h"
  20. #include "filezilla server.h"
  21. #include "OptionsDlg.h"
  22. #include "OptionsPage.h"
  23. #include "OptionsCompressionPage.h"
  24. #include "../iputils.h"
  25.  
  26. COptionsCompressionPage::COptionsCompressionPage(COptionsDlg *pOptionsDlg, CWnd* pParent /*=NULL*/)
  27.     : COptionsPage(pOptionsDlg, COptionsCompressionPage::IDD, pParent)
  28. {
  29. }
  30.  
  31. COptionsCompressionPage::~COptionsCompressionPage()
  32. {
  33. }
  34.  
  35. void COptionsCompressionPage::DoDataExchange(CDataExchange* pDX)
  36. {
  37.     COptionsPage::DoDataExchange(pDX);
  38.     DDX_Text(pDX, IDC_OPTIONS_COMPRESSION_DISALLOWED_IPS, m_disallowedIPs);
  39.     DDX_Check(pDX, IDC_OPTIONS_COMPRESSION_USE, m_UseModeZ);
  40.     DDX_Text(pDX, IDC_OPTIONS_COMPRESSION_LEVELMAX, m_LevelMax);
  41.     DDV_MaxChars(pDX, m_LevelMax, 1);
  42.     DDX_Text(pDX, IDC_OPTIONS_COMPRESSION_LEVELMIN, m_LevelMin);
  43.     DDV_MaxChars(pDX, m_LevelMin, 1);
  44.     DDX_Check(pDX, IDC_OPTIONS_EXCLUDELOCAL, m_DisallowLocal);
  45. }
  46.  
  47.  
  48. BEGIN_MESSAGE_MAP(COptionsCompressionPage, COptionsPage)
  49. END_MESSAGE_MAP()
  50.  
  51. BOOL COptionsCompressionPage::IsDataValid()
  52. {
  53.     UpdateData();
  54.  
  55.     if (_ttoi(m_LevelMin) < 1 || _ttoi(m_LevelMin) > 8)
  56.     {
  57.         m_pOptionsDlg->ShowPage(this);
  58.         GetDlgItem(IDC_OPTIONS_COMPRESSION_LEVELMIN)->SetFocus();
  59.         AfxMessageBox(_T("Minimum compression level must be between 1 and 8"));
  60.         return false;
  61.     }
  62.  
  63.     if (_ttoi(m_LevelMax) < 8 || _ttoi(m_LevelMax) > 9)
  64.     {
  65.         m_pOptionsDlg->ShowPage(this);
  66.         GetDlgItem(IDC_OPTIONS_COMPRESSION_LEVELMAX)->SetFocus();
  67.         AfxMessageBox(_T("Maximum compression level must be between 8 and 9"));
  68.         return false;
  69.     }
  70.  
  71.  
  72.  
  73.     if (!ParseIPFilter(m_disallowedIPs))
  74.     {
  75.         m_pOptionsDlg->ShowPage(this);
  76.         GetDlgItem(IDC_OPTIONS_COMPRESSION_DISALLOWED_IPS)->SetFocus();
  77.         AfxMessageBox(_T("Invalid IP address (range/mask) enterd."));
  78.         return false;
  79.     }
  80.  
  81.     return TRUE;
  82. }
  83.  
  84. void COptionsCompressionPage::SaveData()
  85. {
  86.     m_pOptionsDlg->SetOption(OPTION_MODEZ_USE, m_UseModeZ);
  87.     m_pOptionsDlg->SetOption(OPTION_MODEZ_LEVELMIN, _ttoi(m_LevelMin));
  88.     m_pOptionsDlg->SetOption(OPTION_MODEZ_LEVELMAX, _ttoi(m_LevelMax));
  89.     m_pOptionsDlg->SetOption(OPTION_MODEZ_ALLOWLOCAL, !m_DisallowLocal);
  90.     m_pOptionsDlg->SetOption(OPTION_MODEZ_DISALLOWED_IPS, m_disallowedIPs);
  91. }
  92.  
  93. void COptionsCompressionPage::LoadData()
  94. {
  95.     m_LevelMin.Format(_T("%d"), static_cast<int>(m_pOptionsDlg->GetOptionVal(OPTION_MODEZ_LEVELMIN)));
  96.     m_LevelMax.Format(_T("%d"), static_cast<int>(m_pOptionsDlg->GetOptionVal(OPTION_MODEZ_LEVELMAX)));
  97.     m_UseModeZ = m_pOptionsDlg->GetOptionVal(OPTION_MODEZ_USE) != 0;
  98.     m_DisallowLocal = !m_pOptionsDlg->GetOptionVal(OPTION_MODEZ_ALLOWLOCAL);
  99.     m_disallowedIPs =  m_pOptionsDlg->GetOption(OPTION_MODEZ_DISALLOWED_IPS);
  100. }
  101.